
import 'package:shared_preferences/shared_preferences.dart';
import 'package:thingskit/apiService/ApiService.dart';
import '../utils/const.dart';


class LoginApi extends ApiService {

  LoginApi() : super(thingskitUrl);
  Future<dynamic> login(String username, String password) async {
    final response = await postRequest('/login', {
      'email': username,
      'password': password,
    });
    if (response == null) {
      return null;
    }
    final token = response['token'];
    final prefs = await SharedPreferences.getInstance();
    prefs.setString('token', token);

    return response;
  }
}